from selenium import webdriver
from selenium.webdriver.chrome.options import Options


def get_driver():
    global driver
    # 创建Chrome浏览器的一个Options实例对象
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("user-agent=BDD")

    # 添加屏蔽--ignore--certificate--errors提示信息的设置参数项
    chrome_options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
    # chrome_options.binary_location = "C:\Program Files\Google\Chrome Beta\Application\chrome.exe"

    driver = webdriver.Chrome(executable_path=r"C:\Program Files\Google\Chrome\Application\chromedriver.exe",
                              options=chrome_options)
    driver.maximize_window()
    return driver
